27-Nested Loops_running_totals_code.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

# What is the value of x?
x = 0
for i in range(3):
    x = x + 1
print(x)
 

# What is the value of x?
x = 0
for i in range(3):
    x = x + 1
for j in range(3):
    x = x + 1
print(x)



# What is the value of a?
x = 0
for i in range(3):
    x = x + 1
    for j in range(3):
        x = x + 1
print(x)
                    

Try it yourself